package com.chaoyong.higo.base;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chaoyong.higo.base.BaseActivity;

/**
 * Created by Administrator on 2015/12/4.
 */
public abstract class CopyOfBaseFragment extends Fragment {

	protected View mView;
	protected Context mContext;
	protected LayoutInflater mInflater;

	@Override
	public void onAttach(Activity context) {
		super.onAttach(context);
		mContext = getActivity();
		mInflater = LayoutInflater.from(context);
	}

	@Nullable
	@Override
	public View onCreateView(LayoutInflater inflater,ViewGroup container,
			@Nullable Bundle savedInstanceState) {
		this.mInflater = inflater;
		mView = super.onCreateView(inflater, container, savedInstanceState);
		return mView;
	}


	/**
	 * ��ʾ�����
	 * 
	 * @param cancel
	 */
	public void showLoadingView(boolean cancel) {
		if (getActivity() != null && getActivity() instanceof BaseActivity) {
			((BaseActivity) getActivity()).showLoadingView(cancel);
		}
	}

	/**
	 * ���ؽ����
	 */
	public void hideLoadingView() {
		if (getActivity() != null && getActivity() instanceof BaseActivity) {
			((BaseActivity) getActivity()).hideLoadingView();
		}
	}

	public void showToast(String msg) {
		if (getActivity() != null && getActivity() instanceof BaseActivity) {
			((BaseActivity) getActivity()).showToast(msg);
		}
	}

	public void showToast(int msg) {
		if (getActivity() != null && getActivity() instanceof BaseActivity) {
			((BaseActivity) getActivity()).showToast(msg);
		}
	}

	public void finish() {
		if (getActivity() != null && getActivity() instanceof BaseActivity) {
			((BaseActivity) getActivity()).finish();
		}
	}
}
